home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / DOPbt41 / 4 / rexx / Repack.rexx < prev    next >
OS/2 REXX Batch file  |  1995-04-18  |  3KB  |  96 lines

  1. /* LHA-LZX V1.0 by Mat Bettinson of the Plot Hatching Factory '95
  2.  
  3. Minor bug fix by niels
  4.  
  5. Since Jonathan Forbes' brilliant LZX came along and promptly blew LHA away,
  6. there's a need for a bulk converter. This is such a device.
  7.  
  8. Simply executing the script with the Directory to convert will result
  9. in each and every single LHA or LZH file in that dir being converted to LZX.
  10.  
  11. You'll need LHA and LZX in your path and the Delete command.
  12. It also needs a fat temp dir as large as the largest uncompressed archive
  13. to work and this is the first thing in the script so you can alter at will.
  14.  
  15. Below is the two only real values you must change. One is the Temp Dir where
  16. all LHA files will be extracted to. There must be enough room in this drawer
  17. for the largest of archives to unpack to so I DO NOT recommend RAM: unless you
  18. have a great DEAL of RAM. Beware! LZX eats memory too. The other parameter is
  19. the compression mode. It can be 1,2 or 3 varying from fastest & Lowest CR to 
  20. Slowest & Highest CR. Even mode 1 is better than LHA.
  21.  
  22. New for 2.0:
  23.  
  24. Priority setting in header below.
  25.  
  26. By default, will not replace LHA archives if larger using LZX.
  27.  
  28. Above can be disabled so that ALL files are replaced as per original Repack by
  29. using the 'FORCELZX' switch after the Dir name.
  30.  
  31. Filenotes are copied.
  32. */
  33.  
  34. TempDir  = 'dh2:t/'
  35. Mode     = '3'
  36. Priority = -1
  37.  
  38. /*************************************************/
  39. /* I recommend you leave it alone from here. :-) */
  40. /*************************************************/
  41.  
  42. Arg Dir Force
  43. say 
  44. say ' *** LHA-LZX repacker 2.0 by Mat Bettinson of the Plot Hatching Factory ***'
  45. If Dir = '' then signal Usage
  46. If ~EXISTS(Dir) then signal Usage
  47. If Force ~= '' & Force ~= 'FORCELZX' then signal Usage
  48. If Force = 'FORCELZX' then ForceLZX = 1
  49. ELSE ForceLZX = 0
  50. say
  51. Call Pragma('S',50000)
  52. If right(Dir,1) ~= '/' & right(Dir,1) ~= ':' then Dir = Dir'/'
  53. Address COMMAND 'Assign REPACK: 'Tempdir
  54. Call Pragma('D','REPACK:')
  55. Address COMMAND 'List 'Dir' PAT #?(.LZH|.LHA) FILES LFORMAT "%n %c" >t:LHA-LZX.temp'
  56. Call Open(list,'t:LHA-LZX.temp','R')
  57. BSave = 0
  58. DO forever
  59.  Line = ReadLN(list)
  60.  File = strip(word(line,1)) ; Comment = strip(word(line,2)) ; Comment = Strip(Comment,'B','"')
  61.  IF EOF(list) then break
  62.  NewFile = Left(File,Length(file)-3)'LZX'
  63.  say 'Converting file: 'File
  64.  Address COMMAND 'Delete >NIL: REPACK:#? ALL FORCE'
  65.  Call Open(ts,Dir||file) ; Lhasize = Seek(ts,0,'E') ; Call Close(ts)
  66.  Address COMMAND 'LHA -a -F -M -P'Priority' x 'Dir||File' #? REPACK:'
  67.  Address COMMAND 'LZX -r -e -M500 -'Mode' -P'Priority' -F a 'Dir||NewFile' REPACK:#?'
  68.  Call Open(ts,Dir||NewFile) ; Lzxsize = Seek(ts,0,'E') ; Call Close(ts)
  69.  Diff = Lhasize - Lzxsize
  70.  If Diff > 0 | ForceLZX then DO
  71.   Address COMMAND 'Delete >NIL: 'Dir||File
  72.   If Comment ~= '' then Address COMMAND 'Filenote 'DIR||NewFile' "'Comment'"'
  73.   say '* 'Diff' bytes saved on this archive!' ; say
  74.   END
  75.  ELSE DO
  76.   Address COMMAND 'Delete >NIL: 'Dir||Newfile
  77.   say '* LZX file 'ABS(Diff)' bytes larger than LZX. Keeping LHA...' ; say
  78.   Diff = 0
  79.   END
  80.  BSave = BSave + Diff
  81.  END
  82. Call Close(list)
  83. Address COMMAND 'delete repack:#? all force >nil:'
  84. Address COMMAND 'Assign REPACK: REMOVE'
  85. Address COMMAND 'delete t:LHA-LZX.temp all force >nil:'
  86. say
  87. say ' *** LHA-LZX Repacker 2.0 finished. 'Bsave' bytes saved in this dir. ***'
  88. say
  89. EXIT
  90.  
  91. Usage:
  92. say 
  93. say 'Usage: [rx] Repack <Directory> [FORCELZX]'
  94. say
  95. EXIT
  96.